import { ref } from 'vue'
import { defineStore } from 'pinia'

interface idol {
    avatarUrl: string
    bio: string
    fansCount: number
    id: number
    isAdmin:string
    nickname: string
    recipeCount: number
}

export const useChatStore = defineStore('chat', () => {
  // 当前选中的关注者信息
  const currentIdol = ref<idol>({
    avatarUrl: '',
    bio: '',
    fansCount: 0,
    id: 0,
    isAdmin:'',
    nickname: '',
    recipeCount: 0
  })

  // 设置当前选中的关注者
  function setCurrentIdol(idol: idol) {
    currentIdol.value = { ...idol }
    console.log('设置当前关注者:', currentIdol.value)
  }

  // 获取当前选中的关注者
  function getCurrentIdol() {
    return currentIdol.value
  }


  // chstStroe维护选中关注对象与其getset方法
  return {
    currentIdol,
    setCurrentIdol,
    getCurrentIdol
  }
})
